package com.yj.ccs.abs.boot.pagination;

import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.ReflectionException;
import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;

/**
 * Copyright 2017 (C) Yunjian-VC
 * Created on : 2017/12/8
 * Author     : Unbelievable9
 **/
public class CustomObjectWrapperFactory extends DefaultObjectWrapperFactory {

    @Override
    public boolean hasWrapperFor(Object object) {
        return object instanceof Page;

    }

    @Override
    public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
        if (object instanceof Page) {
            return new CustomObjectWrapper(metaObject, (Page) object);
        }

        throw new ReflectionException("DefaultObjectWrapperFactory 不应该调用 getWrapperFor!");
    }
}
